import java.util.*;

class footballer implements Comparable<footballer> {
    public int number;              // 球员编号
    public int totalGoals;          // 总进球数
    public int maxConsecutiveGoals; // 最大连续进球数
    ArrayList<Integer> miss;        // 丢球

    public footballer(int trains) {
        totalGoals = maxConsecutiveGoals = 0;
        miss = new ArrayList<>(trains);
    }

    @Override
    public int compareTo(footballer o) {
        if (totalGoals != o.totalGoals) {
            return o.totalGoals - totalGoals;
        } else if (maxConsecutiveGoals != o.maxConsecutiveGoals) {
            return o.maxConsecutiveGoals - maxConsecutiveGoals;
        } else {
            int len = Math.min(miss.size(), o.miss.size());
            for (int i = 0; i < len; i++) {
                if (miss.get(i) == o.miss.get(i)) {
                    continue;
                } else {
                    return o.miss.get(i) - miss.get(i);
                }
            }
        }
        return 0;
    }
}

public class code2 {
    static void solve() {
        int numsOfPlayers, trains;
        Scanner sc = new Scanner(System.in);
        numsOfPlayers = sc.nextInt();
        trains = sc.nextInt();
        ArrayList<footballer> players = new ArrayList<>(numsOfPlayers);
        String str;
        for (int i = 0; i < numsOfPlayers; i++) {
            str = sc.next();
            footballer player = new footballer(trains);
            player.number = i + 1;
            int count1 = 0, count2 = 0;
            for (int j = 0; j < trains; j++) {
                if (str.charAt(j) == '1') {
                    count1++;
                    count2++;
                } else {
                    player.maxConsecutiveGoals = Math.max(player.maxConsecutiveGoals, count2);
                    count2 = 0;
                    player.miss.add(j);
                }
            }
            player.maxConsecutiveGoals = Math.max(player.maxConsecutiveGoals, count2);
            player.totalGoals = count1;
            players.add(player);
        }
        Collections.sort(players);
        for (footballer player :
                players) {
            System.out.print(player.number + " ");
        }
        System.out.println();
    }

    static void test1() {
        Scanner sc = new Scanner(System.in);
        int numsOfPlayers, trains;
        numsOfPlayers = sc.nextInt();
        trains = sc.nextInt();
        System.out.println(numsOfPlayers);
        System.out.println(trains);
    }

    //    4 5 11100 00111 10111 01111
    //    2 10 1011100111 1011101101
    public static void main(String[] args) {
        solve();
//        test1();
    }
}
